home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / PPP Interfaces 1.2 / PPP Libraries / source / asmutil.c next >
Encoding:
Text File  |  1996-01-05  |  2.0 KB  |  98 lines  |  [TEXT/CWIE]

  1. /*
  2.  *    Utility assembly routines.
  3.  *
  4.  * Copyright 1992-1993 Merit Network, Inc. and The Regents of the
  5.  *  University of Michigan.  Usage of this source code is restricted
  6.  *  to non-profit, non-commercial purposes.  The source is provided
  7.  *  "as-is", without warranty.
  8.  */
  9.  
  10. // Modified by Richard Buckle 1994 for use with MetroWerks CodeWarrior.
  11. // All functions except bzero() removed, as I don't use them and couldn't
  12. // be bothered to port them.
  13.  
  14. // richardb@cocytus.demon.co.uk
  15.  
  16.  /* Clear a block of memory starting from "ptr" (a0)  */
  17.  /* with size "cnt" bytes (d0) */
  18.  // rewritten by JRB not to use assembler
  19. void bzero(b_8 *ptr, short cnt) 
  20.     {
  21.     short myCount;
  22.     
  23.     for( myCount=0; myCount<cnt; myCount++)
  24.         {
  25.         ptr[myCount] = 0;
  26.         }
  27.     }
  28.  
  29. #if 0 // removed by JRB -- not needed for ppp.interface.c
  30. asm void bzero(b_8 *ptr, short cnt) 
  31.     {
  32.     movea.l    ptr,a0        //get pointer to area to zero
  33.     move.w    cnt,d0        //and its length in bytes
  34.     bra.s    @20
  35.         
  36.     @10        clr.b    (a0)+        //clear a byte
  37.     @20        dbra    d0, @10
  38.     }
  39.  
  40. /*  SetLAPPtr and  GetLAPPtr store and return lap pointer */
  41.  
  42. LapInfo *GetLAPPtr();
  43.  
  44. asm void SetLAPPtr(LapInfo *lap) 
  45.     {
  46.     lea.l    @LapPtr,a0
  47.     move.l    lap,(a0)
  48.     bra.s    @1
  49.  
  50.     extern GetLAPPtr:
  51.         move.l    @LapPtr,d0
  52.         rts
  53.  
  54.     @LapPtr        dc.l    0    /* pointer to LAP variable storage */
  55.     @1
  56.     }
  57.  
  58.  
  59. /* Return the current value of A5, and set A5 to the passed value */
  60. asm long seta5(long v)
  61.     {
  62.     move.l    a5,d0    // return current a5 value
  63.     movea.l    v,a5    // set a5 to new value
  64.     }
  65.  
  66. /* return the current value of A5 */
  67. asm long geta5(void)
  68.     {
  69.     move.l    a5,d0    // return current a5
  70.     }
  71.  
  72. /* Return the current value of A4, and set A4 to the passed value */
  73. asm long seta4(long v)
  74.     {
  75.     move.l    a4,d0    // return current a4 value
  76.     movea.l    v,a4    // set a4 to new value
  77.     }
  78.  
  79. /* just return the current value of A4 */
  80. asm long geta4(void)
  81.     {
  82.     move.l    a4,d0    // return current a4
  83.     }
  84.  
  85. /* set interrupt level */
  86. asm short set_sr(short    v)
  87.     {
  88.     move    sr,d0        // return current sr value
  89.     move    v,sr        // set sr to mask interrupts
  90.     }
  91.  
  92. /* get status register */
  93. asm short get_sr(void)
  94.     {
  95.     move    sr,d0        // get sr value
  96.     }
  97.  
  98. #endif